<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .gray {
            color: gray;
        }
        .black {
            color: black;
        }
        .box {
            width: 200px;
            height: 400px;
        }
        #input {
            background-color: white;
        }
        .list {
            display: block;
            list-style: none;
            width: 200px;
            height: 300px;
        }
    </style>
</head>
<body>
  
    <!-- 6题 -->
    <input type="text" class="gray" value="请输入搜索关键字" id="textSearch">
    <input type="button" value="搜索" id="btnSearch">
    <script>
        var btnSearch = document.getElementById("btnSearch");
        var textSearch = document.getElementById("textSearch");
        textSearch.onfocus = function() {
            if (this.value === "请输入搜索关键字") {
                this.value = "";
                this.className = "black";
            }
        }
        textSearch.onblur = function() {
            if (this.value === "" || this.value === "请输入搜索关键字") {
                this.value = "请输入搜索关键字";
                this.className = "gray";
            }
        }
    </script>
</body>
</html>